﻿using System;
using System.Collections.Generic;
using System.Text;

namespace PCR.Base
{
    /// <summary>
    /// Standard curve sample data interface, contains all the attributes 
    /// of a sample
    /// </summary>
    public interface IStdSampleData : IGuidObject
    {
        /// <summary>
        /// Get or set the cell's CT value
        /// </summary>
        double CTVal { get; set; }

        /// <summary>
        /// Get or set the cell count
        /// </summary>
        UInt64 CellCount { get; set; }

        /// <summary>
        /// Get or set whether to use this sample when calculating the curve 
        /// parameter
        /// </summary>
        bool Valid { get; set;}
    }

    /// <summary>
    /// Standard curve parameter interface
    /// </summary>
    public interface IStdCurveParam
    {
        /// <summary>
        /// Get the curve's k value
        /// Y = -klogX + b,(X : Cell count, Y : Cell CT)
        /// </summary>
        double KVal { get; }

        /// <summary>
        /// Get the curve's b value
        /// Y = -klogX + b,(X : Cell count, Y : Cell CT)
        /// </summary>
        double BVal { get; }

        /// <summary>
        /// Get the cell's exponent coefficient
        /// </summary>
        double EVal { get; }

        /// <summary>
        /// Get the cell's mean deviation 
        /// </summary>
        double RVal { get; }

        /// <summary>
        /// Get the cell's mean square deviation 
        /// </summary>
        double R2Val { get; }
    }

    /// <summary>
    /// Standard curve interface, a curve contains a group of data, 
    /// that could generate a chat present the relationship with Cell CT
    /// and Cell count
    /// </summary>
    public interface IStdCurve : IGuidObject
    {
        /// <summary>
        /// Get or set the standard curve name
        /// </summary>
        string Name { get; set; }

        /// <summary>
        /// Get or set the standard curve description
        /// </summary>
        string Description { get; set; }

        /// <summary>
        /// Sample list, add or remove item from the list
        /// </summary>
        IList<IStdSampleData> SampleDataList { get; }

        /// <summary>
        /// Calculate the revised CT from the sample data and curve parameter
        /// </summary>
        double GetRevisedCT(IStdSampleData sample, IStdCurveParam curveParam);
        
        /// <summary>
        /// Get or set the curve's parameter
        /// </summary>
        IStdCurveParam CurveParam { get; }
    }

    /// <summary>
    /// Standard curve manager, contains all the standard curve operations
    /// </summary>
    public interface IStdCurveManager : IObjectRepository<IStdCurve>
    {
        /// <summary>
        /// Get or set the active standard curve instance,
        /// the virus exponent use this standard curve as the calculation base
        /// </summary>
        IStdCurve Active { get; set; }
    }
}
